package com.jdk8.demo;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Java8_Stream_Distinct {
	
	public static void main(String[] args) throws IOException {

		//找出最长一行的长度
		BufferedReader br = new BufferedReader(new FileReader("C:\\Windows\\setupact.log"));
		List<String> words = br.lines(). flatMap(line -> Stream.of(line.split(" "))).
				 filter(word -> word.length() > 0).
				 map(String::toLowerCase).
				 distinct().
				 sorted().
				 collect(Collectors.toList());
				br.close();
				System.out.println(words);
		
	}

}
